import 'package:dailoz/constants.dart';
import 'package:dailoz/size_config.dart';
import 'package:flutter/material.dart';

class TaskLabel extends StatefulWidget {
  const TaskLabel({
    Key? key,
    required this.labelName,
    required this.status,
  }) : super(key: key);

  final String? labelName;
  final int? status;

  @override
  State<TaskLabel> createState() => _TaskLabelState();
}

class _TaskLabelState extends State<TaskLabel> {
  Color? labelColor;
  Color? labelTextColor;

  void changeLabelColor() {
    switch (widget.status) {
      case 1:
        labelTextColor = completedTaskLabelTextColor;
        labelColor = completedTaskLabelColor;
        break;
      case 2:
        labelTextColor = cancelTaskLabelTextColor;
        labelColor = cancelTaskLabelColor;

        break;
      case 3:
        labelTextColor = pendingTaskLabelTextColor;
        labelColor = pendingTaskLabelColor;

        break;
      case 4:
        labelTextColor = onGoingTaskLabelTextColor;
        labelColor = onGoingTaskLabelColor;
        break;
    }
  }

  @override
  void initState() {
    super.initState();
    changeLabelColor();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(
        vertical: 2.0,
        horizontal: 5.0,
      ),
      height: SizeConfig.getProportionateScreenHeight(22.0),
      decoration: BoxDecoration(
        color: labelColor,
        borderRadius: const BorderRadius.all(
          Radius.circular(5.0),
        ),
      ),
      child: Center(
        child: Text(
          widget.labelName!,
          style: TextStyle(
            color: labelTextColor,
            fontSize: SizeConfig.getProportionateFontSize(11.0),
          ),
        ),
      ),
    );
  }
}
